package com.example.wearing.tools;

import android.content.Context;
import android.graphics.Bitmap;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;

import com.example.wearing.R;
import com.example.wearing.javabean.Match;

import java.util.ArrayList;

public class MatchListAdapter extends ArrayAdapter {
    Context context;
    ArrayList<Match> matchArrayList;
    private static final String TAG = "MatchListAdapter";
    public MatchListAdapter(Context context,
                              int resource,
                              ArrayList<Match> list) {
        super(context, resource, list);
    }


    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        View itemView = convertView;
        if (itemView == null) {
            itemView = LayoutInflater.from(getContext()).inflate(R.layout.clothes_of_match,
                    parent,
                    false);
        }

        Match match = (Match) getItem(position);
        ImageView clothesImg = (ImageView) itemView.findViewById(R.id.clothesImg);

        String imgStr = match.getM_img();
        Bitmap bitmap = ImageUtil.base64ToImage(imgStr);
        clothesImg.setImageBitmap(bitmap);
        return  itemView;
    }
}
